#!/bin/bash
# 定义 vendor 目录的路径
VENDOR_DIR="/app/vendor"
# 配置 composer 镜像源 华为 
# composer config -g repositories.packagist composer https://mirrors.huaweicloud.com/repository/php
# 配置 composer 镜像源 腾讯 
# composer config -g repositories.packagist composer https://mirrors.cloud.tencent.com/composer/
# 配置 composer 镜像源 Cloudflare 
composer config -g repositories.packagist composer https://packagist.pages.dev/
# composer config -g --unset repos.packagist
# 检查 vendor 目录是否存在
if [ ! -d "$VENDOR_DIR" ]; then
    echo "$VENDOR_DIR Running composer install..."
    # 执行 composer install 命令来安装依赖 
    composer install --no-dev
else
    echo "Running composer update..."
    # 执行 composer update 命令来更新依赖
    # rm -rf runtime/webman.pid666
    # composer update --no-dev
fi
# 守护进程启动 webman 服务
# php start.php start -d && tail -f /dev/null
# php start.php start -e APP_ENV=production  -d  && tail -f /dev/null
#   -e APP_ENV=production   生产环境 加载.env.production 文件
php start.php start -e APP_ENV=production 